package com.ysd.shopcar.processor;

import java.lang.invoke.MethodHandles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ysd.shopcar.common.BaseProcesser;
import com.ysd.shopcar.common.BaseUtils;
import com.ysd.shopcar.common.JSONResult;
import com.ysd.shopcar.param.in.AddProductToCarRequestType;
import com.ysd.shopcar.service.ShopCarService;

@Component
public class AddProductToCarProcessor extends BaseProcesser<AddProductToCarRequestType, Object>{
	@SuppressWarnings("unused")
	private static final String Title = MethodHandles.lookup().lookupClass().getSimpleName();

	@Autowired
	private ShopCarService shopCarService;

	@Override
	protected void validate(AddProductToCarRequestType request) {
//		BaseUtils.verifyNotNull(request.getSessionId(), "sessionId不允许为空");
//		BaseUtils.verifyNotNull(request.getServerFrom(), "serverFrom不允许为空");
		BaseUtils.verifyNotNull(request.getName(), "产品名字不允许为空");
		BaseUtils.verifyNotNull(request.getImg(), "产品图片不允许为空");
		BaseUtils.verifyNotNull(request.getPrice(), "产品价格不允许为空");
		BaseUtils.verifyNotNull(request.getUid(), "产品ID不允许为空");
		BaseUtils.verifyNotNull(request.getPid(), "用户ID不允许为空");
		BaseUtils.verifyNotNull(request.getNum(), "产品数量不允许为空");
		BaseUtils.verifyPositive(request.getNum(), "产品个数必须为正数");
	}

	@Override
	protected JSONResult<Object> processing(AddProductToCarRequestType request) throws Exception {
		return shopCarService.addProductToShopCar(request);
	}
	
	

}
